//
//  HJFriendsCell.m
//  project
//
//  Created by hu on 2019/3/25.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJFriendsCell.h"
#import "HJFriendsListModel.h"
@interface HJFriendsCell ()
@property (nonatomic,strong,nonnull) UIView * headSubView;


@end

@implementation HJFriendsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
    }
    return self;
}
-(void)configUI {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
//    UIView * headView = [UIView new];
//    self.headSubView = headView;
//    [headView rounded:(UIRectCornerAllCorners) radius:30 borderColor:[UIColor lightGrayColor] borderWidth:2];
//    [self.contentView addSubview:headView];
    
    UIImageView * headImage = [UIImageView new];
    headImage.image = setImage(@"ico_test_male");
    [headImage rounded:(UIRectCornerAllCorners) radius:20 borderColor:[UIColor blackColor] borderWidth:1];
    self.headImage = headImage;
    [self.contentView addSubview:headImage];
    
    UILabel *nameTitle = [UILabel new];
    nameTitle.textColor = [UIColor colorWithHex:0x000000];
    nameTitle.textAlignment = NSTextAlignmentLeft;
    nameTitle.text = @"B青瓷花羽";
    nameTitle.font = [UIFont fontWithName:PingFangSC_Medium size:15];
    self.name = nameTitle;
    [self.contentView addSubview:nameTitle];
    
    UILabel * prompt = [UILabel new];
    prompt.textColor = [UIColor colorWithHex:0xffffff];
    prompt.backgroundColor = [UIColor colorWithHex:0xFF2400];
    prompt.textAlignment = NSTextAlignmentCenter;
    [prompt rounded:UIRectCornerAllCorners radius:10];
//    prompt.text = @"2";
    prompt.font = [UIFont fontWithName:PingFangSC_Medium size:10];
    self.promptLabel = prompt;
    [self.contentView addSubview:prompt];
}

-(void)layoutSubviews {
    [super layoutSubviews];
//    CGRect subRect;
//    subRect.origin.x = 12;
//    subRect.origin.y = self.contentView.centerY-30;
//    subRect.size.width = 40;
//    subRect.size.height = subRect.size.width;
//    self.headSubView.frame = subRect;
    
    CGRect headRect;
    headRect.origin.x = 8;
    headRect.origin.y = headRect.origin.x;
    headRect.size.width = 40;
    headRect.size.height = headRect.size.width;
    self.headImage.frame = headRect;
    
    CGRect nameRect;
    nameRect.origin.x = headRect.size.width + 8+9;
    nameRect.origin.y = self.contentView.centerY-10;
    nameRect.size.width = self.contentView.width- nameRect.origin.x -40;
    nameRect.size.height = 20;
    self.name.frame = nameRect;
    
    CGRect promptRect;
    promptRect.origin.x = self.contentView.width-30;
    promptRect.origin.y = nameRect.origin.y;
    promptRect.size.width = 20;
    promptRect.size.height = promptRect.size.width;
    self.promptLabel.frame = promptRect;
    
}

-(void)loadFriendsData:(HJListModel *)listModel {
    self.name.text = listModel.nickName;
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:listModel.avatar]];
}
@end
